package org.algorithm.二师兄.字符串;

import org.junit.Test;

/**
 * @Date 2022/2/23
 * @Link {https://leetcode-cn.com/problems/excel-sheet-column-number/}
 */
public class Excel表列序号 {

    @Test
    public void test() {
        System.out.println(titleToNumber("ABCD"));
    }

    public int titleToNumber(String s) {
        int res = 0;
        char[] chars = s.toCharArray();
        for(char c : chars) {
            int temp = c - 'A' + 1;
            res = res * 26 + temp;
        }
        return res;
    }
}
